<template>
  <el-dialog
      title="新增组件分类"
      v-el-drag-dialog
      v-if="showDom"
      :visible.sync="visible"
      width="520px"
      center
      :show-close="false"
      @closed="closed">
    <div class="libBody">
      <el-form
          :model="form"
          ref="basicForm"
          label-width="100px">
        <el-form-item label="分类名称" prop="pluginsName">
          <el-input v-model="form.libraryName" placeholder="请填写组件分类名称"></el-input>
        </el-form-item>
      </el-form>
      <span></span>
    </div>

    <div slot="footer" class="dialog-footer">
      <el-button size="small" type="" @click="hide">关 闭</el-button>
      <el-button size="small" type="primary" @click="confirmTap">添 加</el-button>
    </div>
  </el-dialog>
</template>

<script>
import {
  put_pluginsAdd,
  put_PRequireAdd,
  get_getSystem,
  get_getPClass,
  put_funactonAdd,
  put_paramAdd,
  put_monitorAdd,
  put_switchAdd,
  post_loadDll,
  put_libraryAdd,
  get_getFunctionByPluginsId,
  get_getPLibrarySelect,
  put_addPLibrary,
} from "@/apis/assembly/assembly";

export default {
  props: {},
  data() {
    return {
      showDom: false,
      visible: false,
      form: {
        libraryName: ''
      },
      lists: []
    };
  },
  computed: {},
  mounted() {

  },
  created() {

  },
  methods: {
    show(data) {
      this.showDom = true
      this.visible = true
      this.lists = data
    },
    hide() {
      this.visible = false
    },
    closed() {
      this.showDom = false
    },
    // 确定添加lib
    confirmTap() {
      if (!this.form.libraryName) {
        return this.$message.warning('请填写分类名称！')
      }
      put_addPLibrary({libraryName: this.form.libraryName}).then((res) => {
        let {code, msg} = res.data;
        if (code === 0) {
          this.hide()
          this.$message.success(msg);
          this.$emit('success')
        }
      });
      this.$emit('test', this.lists[0].data.id)
    }
  }
};
</script>
<style lang="less" scoped>
  .form-box-group {
    max-height: 500px;
    overflow: hidden;
    overflow-y: auto;
  }

  .form-box-item {
    padding: 15px 50px 15px 15px;
    border-bottom: solid 1px #ffffff;

    &:last-child {
      border-bottom: none;
    }
  }
</style>